package com.edu.web;


import com.edu.service.ProvinceService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(value = "/findProvince", name = "FindProvinceServlet")
public class FindProvinceServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //请求中文乱吗
        request.setCharacterEncoding("utf-8");
        //响应JSON字符串给前台
        response.setContentType("application/json;charset=utf-8");

        String provinces = ProvinceService.getProvinces();
        response.getWriter().write(provinces);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
